#include <iostream>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	string str[101];
	char t=' ';
	int i=0;
	while(t!='\n'){
		cin>>str[i];
		t=getchar();
		i++;
	}

	for(int j=n-m;j<n;j++){
		cout<<str[j]<<" ";
	}
	for(int j=0;j<n-m;j++){
		cout<<str[j]<<" ";
	}
	return 0;

}
